<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>P129 【例6-1】demo01.html</title>
</head>

<body>
    <p><input type="button" value="打开窗口" onclick="openWin()"></p>
    <p><input type="button" value="关闭窗口" onclick="closeWin()"></p>
    <p><input type="button" value="检测窗口是否关闭" onclick="openWin()"></p>
    <p id="msg"></p>
    <script>
        var myWindow;
        function openWin() {
            myWindow = window.open('', 'newWin', 'width=400,height=200,left=200');
            myWindow.document.write('<p>窗口名称为：' + myWindow.name + '</p>');
            myWindow.document.write('<p>当前窗口的父窗口地址：' + window.parent.location + '</p>');
        }
        function closeWin() {
            myWindow.close();
        }
        function checkWin() {
            if (myWindow) {
                var str = myWindow.closed ? '窗口已关闭！' : '窗口未关闭！';
            } else {
                var str = '窗口没有被打开！';
            }
            document.getElementById('msg').innerHTML = str;
        }
    </script>
    <a href="../首页/page06.html">
        <h2>返回上一页面</h2>
    </a>
</body>

</html>